﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;

namespace Mimoza.GUI
{
    public class WizardPage : UserControl, IWizardPage
    {
        private IWizard m_wizard;
        private string m_pageName;
        private string m_pageTitle;
        private bool m_IsConfigured = true;

        protected void RaiseOnPageModified()
        {
            PageEvent handler = OnPageModified;

            if (handler != null)
            {
                handler(this);
            }
        }
        public void Init(IWizard wizard) 
        {
            m_wizard = wizard;
            Init();
        }
        virtual public void Init()
        { }
        virtual public void EnterPage()
        {
        }
        virtual public bool Try2LeavePage(WizardPageLeavingDirection direction)
        {
            return true;
        }

        public IWizard Wizard
        {
            get
            {
                return m_wizard;
            }
        }
        [Category("IWizardPage")]
        [Localizable(true)]
        public string PageName 
        { 
            get
            {
                return m_pageName;
            }
            set 
            {
                m_pageName = value;
            }
        }
        [Category("IWizardPage")]
        [Localizable(true)]
        public string PageTitle
        {
            get
            {
                return m_pageTitle;
            }
            set
            {
                m_pageTitle = value;
            }
        }
        public bool IsConfigured 
        {
            get 
            {
                return m_IsConfigured;
            }
            set
            {
                if (m_IsConfigured != value)
                {
                    m_IsConfigured = value;
                    //RaiseOnPageModified();
                }
            }
        }

        public event PageEvent OnPageModified;
    }
}
